﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INSTA.AI97.BankApp.BLL
{
    /// <summary>
    /// Static factory class to create Accounts.
    /// </summary>
    public static class AccountFactory
    {
        /// <summary>
        /// Creates the specified account type depending on 
        /// the deposit amount..
        /// </summary>
        /// <param name="holder">The holder.</param>
        /// <param name="deposit">The deposit.</param>
        /// <returns></returns>
        public static AccountBase Create(Customer holder, double deposit)
        {
            AccountBase result = null;

            if (deposit > 0 && deposit <= 1000)
            {
                result = new SimpleAccount(holder, deposit);
            }
            else if (deposit > 1000 && deposit <= 2000)
            {
                result = new SilverAccount(holder, deposit);
            }
            else if (deposit > 2000)
            {
                result = new GoldAccount(holder, deposit);
            }
            else
            {
                throw new Exception("Negative deposit");
            }

            // on fait renvoyer le compte créé.
            return result;

        }









    }
}
